<?php
// $Id: results.tpl.php,v 1.5 2007/10/11 09:51:29 goba Exp $
global $base_url,$language;
  $url = $base_url . '/' . drupal_get_path('module', 'forms');
//print_r($catid);
//print "<pre>";print_r($items); print"</pre>";
 

?>
			
		<?php 
		global $shemeblockArr,$serviceblockArr;
		$i=0;           
		 foreach($items as $nid){
		 	my_db_change(1);
		 	$vid = db_query('SELECT vid FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetchField();
		 	$row = node_load($nid, $vid);
		 	my_db_change(0);
		 	
		 if ($row->field_form_upload['und'][0]['filesize'] != '0') {
			$kb = ceil($row->field_form_upload['und'][0]['filesize']/1024);
			$kbyte= $kb.KB;
			if($kb >1024) { 
			  $kb = ceil($kb/1024);
			  $kbyte= $kb.MB;
			}
		}
		 if ($row->field_form_type['und'][0]['value'] == 'online') {
			$link =  $row->field_form_avail['und'][0]['value'];
			$link ="'$link'";
			$icon ='';
		}
		else if($row->field_form_type['und'][0]['value'] == 'download') {
		     $link= $row->field_form_upload['und'][0]['uri'];		
		     $wrapper = file_stream_wrapper_get_instance_by_uri($link);
			if($wrapper == true){
				 $pathfile = $wrapper->getDirectoryPath() . "/" . file_uri_target($link);
			}
			/*$split=explode('dorms/',$pdf_url);
			$onclick_url=$split[1];*/
			$link="'http://cms.tn.gov.in/tncms_latest/$pathfile '";
			$icon = '<img alt="Download Icon" src="http://cms.tn.gov.in/sites/default/files/icons/pdf_icon.gif">
						<span class="kb">
							<span>('.$kbyte.')</span>
						</span>		';
		}
		
		?>
			<div class="res_title_ch" style="">
				 <p><a onclick="return tnportal_window(<?php print $link ?>);" href="javascript:void(0);" >
						<?php echo  ucfirst(t($row->title)).$icon ?>
					</a>
				 </p>
			</div>	
			<?php
		if(!empty($row->field_form_schemes['und'][0]['value'])) {
            $scheme_id = $row->field_form_schemes['und'][0]['value'];
            $scheme=  GetSchemeDetails($scheme_id); // GetSchemeDetails(27187);
            print_r($scheme_id);
            $shemeblockArr[$scheme_id] = array("schemnid"=>$scheme['nid'],"schemetitle"=>$scheme['title']);
        }?>
        <?php
        //$row->field_form_services['und'][0]['value'] = 20075;
        if(!empty($row->field_form_services['und'][0]['value'])) {
          $service_id = $row->field_form_services['und'][0]['value'];
          $service=GetServiceDetails($service_id);
          if($service->nid!=''){
        	  	if(empty($service->field_src_upload_fid)){
        				$filepath = $service->field_src_website['und'][0]['value'];
        		}else{
        			  $filepath = BASECH.$rows->filepath;
        			  $icon = get_pdf_icon($rows->filepath);
        		}
        	$serviceblockArr[$service_id] = array("servicepath"=>$filepath,"servicetitle"=>ucfirst($service->title));
          }
        } ?>		
		<?php $i++; } ?>
		<?php if($i == '0'){?>
			 <div class="no_record">No Results Found </div>
		<?php }	?>
	</div>
<div class="clr"></div>
</div>

